import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {NzMessageService, NzModalRef, NzModalService} from 'ng-zorro-antd';

@Injectable()
export class UtilService {

  constructor(private http: HttpClient,
              private modal: NzModalService,
              private message: NzMessageService) {
  }

  comfirm(text: string, callback): void {
    let confirmModal: NzModalRef;
    confirmModal = this.modal.confirm({
      nzTitle: text,
      nzOnOk: () => {
        callback();
      }
    });
  }

  remind(type: string, text: string): void {
    this.message.create(type, text);
  }

  getUserInfo(): Promise<any> {
    return new Promise((resolve, reject) => {
      resolve({status: 1, userGuid: '96a5f559-590e-0c9a-8cb9-1f4b1f57f456'})
    })
    // return this.http.get(`/api/userInfo`).toPromise().then(res => {
    //   return res;
    // })
  }

  logout(): Promise<any> {
    return this.http.get(`/logout`).toPromise().then(res => {
      return res;
    })
  }
}
